package com.example.socialwebserver.controller;

import com.example.socialwebserver.pojo.*;
import  com.example.socialwebserver.service.ExpectFriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class ExpectFriendController {
    @Autowired
    ExpectFriendService expectFriendService;

    @RequestMapping("expectFriend/SelectById")
    public ServerResult SelectById(Integer id){
        ExpectFriendDAO expectFriendDAO = expectFriendService.SelectById(id);
        return expectFriendDAO == null?new ServerResult(0,"失败",null):
                new ServerResult(0,"成功",expectFriendDAO);
    }
    @RequestMapping("expectFriend/InsertExFrDAO")
    public ServerResult InsertExFrDAO(ExpectFriendDAO expectFriendDAO){
        boolean b = expectFriendService.InsertExFrDAO(expectFriendDAO);
        return b == true?new ServerResult(0,"添加成功",b): new ServerResult(0,"添加失败",b);
    }
    @RequestMapping("expectFriend/DeleteById")
    public ServerResult DeleteById(Integer id){
        boolean b = expectFriendService.DeleteById(id);
        return b == true?new ServerResult(0,"添加成功",b): new ServerResult(0,"添加失败",b);
    }
    @RequestMapping("expectFriend/UpdateById")
    public ServerResult UpdateById(ExpectFriendDAO expectFriendDAO) {
        boolean b = expectFriendService.UpdateById(expectFriendDAO);
        return b == true?new ServerResult(0,"修改成功",b): new ServerResult(0,"修改失败",b);
    }

}
